package org.dromara.oce.controller.admin;

import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.http.HttpStatus;
import com.alibaba.fastjson.JSONObject;
import com.bytedance.ads.model.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.ObjectUtils;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.oce.domain.OceAccount;
import org.dromara.oce.domain.dto.ProjectPromotionAggregation;
import org.dromara.oce.domain.qo.*;
import org.dromara.oce.domain.req.*;
import org.dromara.oce.domain.vo.*;
import org.dromara.oce.service.OceAccountService;
import org.dromara.oce.service.OceMicroAppService;
import org.dromara.oce.service.OceMicroWechatAppService;
import org.dromara.oce.service.remote.OceanEngineThirdRemoteService;
import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 巨量第三方接口
 *
 * @desc:
 * @author: hhl
 * @date：2025/5/30 16:54
 * @module 管理平台接口
 */
@SaIgnore
@Slf4j
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/oce/third")
public class OceThirdController {

    private final OceanEngineThirdRemoteService oceanEngineThirdRemoteService;
    private final OceMicroAppService oceMicroAppService;
    private final OceMicroWechatAppService wechatAppService;
    private final OceAccountService oceAccountService;


    /**
     * 查询账号下的广告主列表
     *
     * @param qo
     * @param pageQuery
     * @return
     */
    @GetMapping("/getAccountAdvertiserList")
    public TableDataInfo<GetAccountAdvertiserListVo> getAccountAdvertiserList(GetAccountAdvertiserlistQo qo) {
        if(!ObjectUtils.isEmpty(qo.getAdvertiserId())){
            List<AgentAdvertiserInfoQueryV2ResponseDataAccountDetailListInner> advertiserInfo = oceanEngineThirdRemoteService.getAdvertiserInfo(qo.getAccountId(), Arrays.asList(qo.getAdvertiserId()));
            if (advertiserInfo != null && advertiserInfo.size() > 0) {
                qo.setAdvertiserName(advertiserInfo.get(0).getAdvertiserName());
            }
        }else if (!ObjectUtils.isEmpty(qo.getAdvertiserIdStr())) {
            TableDataInfo<GetAccountAdvertiserListVo> rspData = new TableDataInfo<>();
            rspData.setCode(HttpStatus.HTTP_OK);
            rspData.setMsg("查询成功");

            try {
                // 1. 解析ID列表，增加异常处理
                List<Long> idList;
                try {
                    idList = Arrays.stream(qo.getAdvertiserIdStr().split(","))
                        .map(String::trim)
                        .filter(s -> !s.isEmpty()) // 过滤空字符串
                        .map(Long::valueOf)
                        .collect(Collectors.toList());
                } catch (NumberFormatException e) {
                    rspData.setCode(HttpStatus.HTTP_BAD_REQUEST);
                    rspData.setMsg("广告主ID格式错误");
                    return rspData;
                }

                // 2. 获取广告主信息，增加null检查
                List<AgentAdvertiserInfoQueryV2ResponseDataAccountDetailListInner> advertiserInfo =
                    oceanEngineThirdRemoteService.getAdvertiserInfo(qo.getAccountId(), idList);

                if (CollectionUtils.isEmpty(advertiserInfo)) {
                    rspData.setRows(Collections.emptyList());
                    rspData.setTotal(0L);
                    return rspData;
                }

                // 3. 处理结果
                List<GetAccountAdvertiserListVo> respList = new ArrayList<>();
                long totalNumber = 0L;

                for (AgentAdvertiserInfoQueryV2ResponseDataAccountDetailListInner data : advertiserInfo) {
                    if (data == null) continue;

                    qo.setAdvertiserName(data.getAdvertiserName());

                    try {
                        CustomerCenterAdvertiserListV2ResponseData page =
                            oceanEngineThirdRemoteService.getCustomerCenterAdvertiserList(qo);

                        if (page != null && page.getList() != null) {
                            for (CustomerCenterAdvertiserListV2ResponseDataListInner inner : page.getList()) {
                                if (inner == null) continue;

                                GetAccountAdvertiserListVo dto = new GetAccountAdvertiserListVo();
                                dto.setAdvertiserId(inner.getAdvertiserId());
                                dto.setAdvertiserName(inner.getAdvertiserName());
                                respList.add(dto);
                            }

                            if (page.getPageInfo() != null) {
                                totalNumber += page.getPageInfo().getTotalNumber();
                            }
                        }
                    } catch (Exception e) {
                        // 记录日志，继续处理下一个广告主
                        log.error("获取广告主列表失败, advertiserId: {}", data.getAdvertiserId(), e);
                    }
                }

                rspData.setRows(respList);
                rspData.setTotal(totalNumber);

            } catch (Exception e) {
                log.error("处理广告主查询请求异常", e);
                rspData.setCode(HttpStatus.HTTP_INTERNAL_ERROR);
                rspData.setMsg("系统繁忙，请稍后再试");
            }

            return rspData;
        } else if (!ObjectUtils.isEmpty(qo.getAdvertiserName()) && qo.getAdvertiserName().length() > 10 && NumberUtil.isNumber(qo.getAdvertiserName())) {
            List<AgentAdvertiserInfoQueryV2ResponseDataAccountDetailListInner> advertiserInfo = oceanEngineThirdRemoteService.getAdvertiserInfo(qo.getAccountId(), Arrays.asList(Long.parseLong(qo.getAdvertiserName())));
            if (advertiserInfo != null && advertiserInfo.size() > 0) {
                qo.setAdvertiserName(advertiserInfo.get(0).getAdvertiserName());
            }
        }

        CustomerCenterAdvertiserListV2ResponseData page = oceanEngineThirdRemoteService.getCustomerCenterAdvertiserList(qo);
        List<Long> advertiserIds = page.getList().stream().map(CustomerCenterAdvertiserListV2ResponseDataListInner::getAdvertiserId).collect(Collectors.toList());
//        List<AgentAdvertiserInfoQueryV2ResponseDataAccountDetailListInner> advertiserInfoList = oceanEngineThirdRemoteService.getAdvertiserInfo(qo.getAccountId(), advertiserIds);
//        Map<Long, AgentAdvertiserInfoQueryV2ResponseDataAccountDetailListInner> advertiserMap = advertiserInfoList.stream().collect(Collectors.toMap(item -> item.getAdvertiserId(), item -> item));

        List<GetAccountAdvertiserListVo> respList = new ArrayList<>();
        for (CustomerCenterAdvertiserListV2ResponseDataListInner inner : page.getList()) {
            GetAccountAdvertiserListVo dto = new GetAccountAdvertiserListVo();
            dto.setAdvertiserId(inner.getAdvertiserId());
            dto.setAdvertiserName(inner.getAdvertiserName());
//            AgentAdvertiserInfoQueryV2ResponseDataAccountDetailListInner advertiserInfo = advertiserMap.get(inner.getAdvertiserId());
//            dto.setAdvCompanyName(advertiserInfo.getAdvCompanyName());
            respList.add(dto);
        }

        TableDataInfo<GetAccountAdvertiserListVo> rspData = new TableDataInfo<>();
        rspData.setCode(HttpStatus.HTTP_OK);
        rspData.setMsg("查询成功");
        rspData.setRows(respList);
        rspData.setTotal(page.getPageInfo().getTotalNumber());
        return rspData;
    }

    /**
     * 上传广告主账户头像
     * 格式要求：bmp,jpeg,jpg,png
     * 文件大小：<=5M
     * 像素：<=300*300
     *
     * @param req
     * @return 账户头像图片ID
     */
//    @PostMapping(value = "/uploadAdvertiserAvatar", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
//    public R<String> uploadAdvertiserAvatar(UploadImageReq req) {
//        File file = FileUtil.convertToFile(req.getFile());
//        String imageId = oceanEngineThirdRemoteService.uploadAdvertiserAvatar(req.getAdvertiserId(), file);
//        return R.ok(imageId);
//    }

    /**
     * 更新广告主账号头像
     *
     * @param req
     * @return
     */
    @PostMapping(value = "/updateAdvertiserAvatar")
    public R<String> updateAdvertiserAvatar(@RequestBody UpdateAdvertiserAvatarReq req) {
        OceAccount oceAccount = oceAccountService.getById(req.getAccountId());
        Assert.notNull(oceAccount,"未找到管家账号");

        req.setThirdAdvertiserAppCode(oceAccount.getThirdAdvertiserAppCode());
        for (Long advertiserId : req.getAdvertiserIds()) {
            req.setAdvertiserId(advertiserId);
            try {
                oceanEngineThirdRemoteService.updateAdvertiserAvatar(req);
            } catch (Exception e) {
                throw new ServiceException("修改头像失败，广告主："+advertiserId);
            }
        }
        return R.ok();
    }

    /**
     * 获取绑定的抖音号
     * @param qo
     * @return
     */
    @GetMapping("/getIesAccountSearch")
    public R<List<GetIesAccountSearchVo>> getIesAccountSearch(GetIesAccountSearchQo qo){
        qo.checkParam();
        return R.ok(oceanEngineThirdRemoteService.getIesAccountSearch(qo));
    }


    /**
     * 获取工作台（原纵横组织）下所有主体
     * https://open.oceanengine.com/labels/7/docs/1741478619724813?origin=left_nav
     *
     * @param qo
     * @return
     */
    @GetMapping("/getAccountAllCompanyInfo")
    public TableDataInfo<BusinessPlatformCompanyInfoGetV30ResponseDataCompanyInfoInner> getAccountAllCompanyInfo(GetAccountAllCompanyInfoQo qo) {
        BusinessPlatformCompanyInfoGetV30ResponseData page = oceanEngineThirdRemoteService.getAccountAllCompanyInfo(qo);

        TableDataInfo<BusinessPlatformCompanyInfoGetV30ResponseDataCompanyInfoInner> rspData = new TableDataInfo<>();
        rspData.setCode(HttpStatus.HTTP_OK);
        rspData.setMsg("查询成功");
        rspData.setRows(page.getCompanyInfo());
        rspData.setTotal(page.getPageInfo().getTotalNumber());
        return rspData;
    }


    /**
     * 查询商品库列表
     * https://open.oceanengine.com/labels/7/docs/1696710577036288?origin=left_nav
     *
     * @param accountId
     * @param advertiserId
     * @return
     */
    @GetMapping("/getProductStoreList")
    public R<List<GetProductStoreListVo>> getProductStoreList(GetProductStoreListQo qo) {
        qo.checkParam();
        List<GetProductStoreListVo> respList = new ArrayList<>();
        List<DpaProductAvailablesV2ResponseDataListInner> resultList = oceanEngineThirdRemoteService.getDptProductAvailablesList(qo.getAccountId(), qo.getAdvertiserId());
        for (DpaProductAvailablesV2ResponseDataListInner dd : resultList) {
            GetProductStoreListVo vo = BeanUtil.copyProperties(dd, GetProductStoreListVo.class);
            vo.setAdvertiserId(qo.getAdvertiserId());
            respList.add(vo);
        }
        return R.ok(respList);
    }

    /**
     * 查询商品库分类
     * @param qo
     * @return
     */
    @GetMapping("/getProductStoreCatetoryList")
    public R<List<ProductStoreCatetoryVo>> getProductStoreCatetoryList(GetProductStoreListQo qo){
        qo.checkParam();
        List<ProductStoreCatetoryVo> respList = new ArrayList<>();
        List<GetProductStoreListVo> iaaList = new ArrayList<>();
        List<GetProductStoreListVo> iapList = new ArrayList<>();

        List<DpaProductAvailablesV2ResponseDataListInner> resultList = oceanEngineThirdRemoteService.getDptProductAvailablesList(qo.getAccountId(), qo.getAdvertiserId());
        for (DpaProductAvailablesV2ResponseDataListInner dd : resultList) {
            GetProductStoreListVo vo = BeanUtil.copyProperties(dd, GetProductStoreListVo.class);
            vo.setAdvertiserId(qo.getAdvertiserId());
            if("IAAPLAYLET".equals(dd.getProductIndustry().name())){
                iaaList.add(vo);
            }else if("PLAYLET".equals(dd.getProductIndustry().name())){
                iapList.add(vo);
            }
        }

        ProductStoreCatetoryVo iaa = new ProductStoreCatetoryVo();
        iaa.setProductStoreCatetoryName("免费短剧库");
        iaa.setProductStoreList(iaaList);

        ProductStoreCatetoryVo iap = new ProductStoreCatetoryVo();
        iap.setProductStoreCatetoryName("付费短剧库");
        iap.setProductStoreList(iapList);

        respList.add(iap);
        respList.add(iaa);
        return R.ok(respList);
    }

    /**
     * 获取商品库下 -> 商品列表
     * https://open.oceanengine.com/labels/7/docs/1696710578078732?origin=left_nav
     *
     * @return
     */
    @GetMapping("/getDpaProductList")
    public R<List<DpaDetailGetV2ResponseDataListInner>> getDpaProductList(GetDptProductListPageQo qo) {
        qo.checkParam();
        List<DpaDetailGetV2ResponseDataListInner> dptProductList = oceanEngineThirdRemoteService.getDptProductList(qo);
        return R.ok(dptProductList);
    }

    /**
     * 查询多个商品详情
     * @param qo
     * @return
     */
    @GetMapping("/getProductDetail")
    public R<DpaProductDetailGetV2ResponseDataListInner> getProductDetail(GetProductDetailQo qo) {
        qo.checkParam();
        DpaProductDetailGetV2ResponseData page =  oceanEngineThirdRemoteService.getProductDetail(qo);
        if(page.getList()==null || page.getList().size()==0){
            return R.ok();
        }
        return R.ok(page.getList().get(0));
    }



    /**
     * 创建DPA商品（无商品id）
     *
     * @param req
     * @return
     */
    @PostMapping("/createDptProduct")
    public R createDptProduct(@RequestBody @Validated CreateDptProductReq req) {
        req.checkParam();
        boolean isOk = oceanEngineThirdRemoteService.createDptProduct(req);
        return R.isOk(isOk);
    }

    /**
     * 批量修改DPA商品投放状态
     *
     * @param req
     * @return
     */
    @PostMapping("/updateBatchProductStatus")
    public R updateBatchProductStatus(@RequestBody @Validated UpdateBatchProductStatusReq req) {
        req.checkParam();
        boolean isOK = oceanEngineThirdRemoteService.updateBatchProductStatus(req);
        return R.isOk(isOK);
    }

    /**
     * 应用管理标签及类目 （https://open.oceanengine.com/labels/7/docs/1812331394774028?origin=left_nav）
     *
     * @param type 1-字节小程序；2-微信小程序；
     * @return
     */
    @GetMapping("/getTagInfo")
    public R<JSONObject> getTagInfo(Integer type) {
        if (type == 1) {
            String jsonStr = "{\"category_name\":\"小程序\",\"categories\":[{\"category_name\":\"短剧\",\"categories\":[{\"category_name\":\"都市\",\"categories\":[{\"category_id\":1050101001,\"category_name\":\"神医\"},{\"category_id\":1050101002,\"category_name\":\"赘婿\"},{\"category_id\":1050101003,\"category_name\":\"鉴宝\"},{\"category_id\":1050101004,\"category_name\":\"战神\"},{\"category_id\":1050101005,\"category_name\":\"神豪\"},{\"category_id\":1050101006,\"category_name\":\"系统\"},{\"category_id\":1050101007,\"category_name\":\"校园\"},{\"category_id\":1050101008,\"category_name\":\"职场\"},{\"category_id\":1050101009,\"category_name\":\"官场\"},{\"category_id\":1050101010,\"category_name\":\"家庭\"},{\"category_id\":1050101011,\"category_name\":\"乡村\"},{\"category_id\":1050101012,\"category_name\":\"异能\"},{\"category_id\":1050101013,\"category_name\":\"其他\"}]},{\"category_name\":\"悬疑\",\"categories\":[{\"category_id\":1050102001,\"category_name\":\"灵异\"},{\"category_id\":1050102002,\"category_name\":\"悬疑推理\"},{\"category_id\":1050102003,\"category_name\":\"其他\"}]},{\"category_name\":\"现言\",\"categories\":[{\"category_id\":1050103001,\"category_name\":\"虐恋\"},{\"category_id\":1050103002,\"category_name\":\"甜宠\"},{\"category_id\":1050103003,\"category_name\":\"萌宝\"},{\"category_id\":1050103004,\"category_name\":\"总裁\"},{\"category_id\":1050103005,\"category_name\":\"腹黑\"},{\"category_id\":1050103006,\"category_name\":\"替身\"},{\"category_id\":1050103007,\"category_name\":\"娱乐明星\"},{\"category_id\":1050103008,\"category_name\":\"其他\"}]},{\"category_name\":\"古言\",\"categories\":[{\"category_id\":1050104001,\"category_name\":\"宫斗宅斗\"},{\"category_id\":1050104002,\"category_name\":\"种田经商\"},{\"category_id\":1050104003,\"category_name\":\"穿越\"},{\"category_id\":1050104004,\"category_name\":\"战争\"},{\"category_id\":1050104005,\"category_name\":\"其他\"}]},{\"category_name\":\"军事\",\"categories\":[{\"category_id\":1050105001,\"category_name\":\"穿越战争\"},{\"category_id\":1050105002,\"category_name\":\"现代军事\"},{\"category_id\":1050105003,\"category_name\":\"其他\"}]},{\"category_name\":\"玄幻\",\"categories\":[{\"category_id\":1050106001,\"category_name\":\"奇幻仙侠\"},{\"category_id\":1050106002,\"category_name\":\"科幻脑洞\"},{\"category_id\":1050106003,\"category_name\":\"架空玄幻\"},{\"category_id\":1050106004,\"category_name\":\"其他\"}]},{\"category_name\":\"其他剧情\",\"categories\":[{\"category_id\":1050107001,\"category_name\":\"其他\"}]}]},{\"category_name\":\"小说\",\"categories\":[{\"category_name\":\"奇幻玄幻\",\"categories\":[{\"category_id\":1050201001,\"category_name\":\"异世冒险\"},{\"category_id\":1050201002,\"category_name\":\"西方奇幻\"},{\"category_id\":1050201003,\"category_name\":\"东方玄幻\"},{\"category_id\":1050201004,\"category_name\":\"魔法异能\"}]},{\"category_name\":\"武侠仙侠\",\"categories\":[{\"category_id\":1050202001,\"category_name\":\"武侠江湖\"},{\"category_id\":1050202002,\"category_name\":\"仙侠修真\"},{\"category_id\":1050202003,\"category_name\":\"洪荒封神\"},{\"category_id\":1050202004,\"category_name\":\"脑洞修仙\"},{\"category_id\":1050202005,\"category_name\":\"长生\"}]},{\"category_name\":\"历史军事\",\"categories\":[{\"category_id\":1050203001,\"category_name\":\"历史架空\"},{\"category_id\":1050203002,\"category_name\":\"历史传记\"},{\"category_id\":1050203003,\"category_name\":\"历史穿越\"},{\"category_id\":1050203004,\"category_name\":\"谍战\"}]},{\"category_name\":\"都市社会\",\"categories\":[{\"category_id\":1050204001,\"category_name\":\"都市职场\"},{\"category_id\":1050204002,\"category_name\":\"影视娱乐\"},{\"category_id\":1050204003,\"category_name\":\"青春校园\"},{\"category_id\":1050204004,\"category_name\":\"都市生活\"},{\"category_id\":1050204005,\"category_name\":\"都市异能\"},{\"category_id\":1050204006,\"category_name\":\"种田萌娃\"},{\"category_id\":1050204007,\"category_name\":\"家庭伦理\"}]},{\"category_name\":\"科幻末世\",\"categories\":[{\"category_id\":1050205001,\"category_name\":\"末世求生\"},{\"category_id\":1050205002,\"category_name\":\"未来文明\"},{\"category_id\":1050205003,\"category_name\":\"赛博朋克\"},{\"category_id\":1050205004,\"category_name\":\"机甲星际\"},{\"category_id\":1050205005,\"category_name\":\"平行世界\"},{\"category_id\":1050205006,\"category_name\":\"异类接触\"}]},{\"category_name\":\"灵异悬疑\",\"categories\":[{\"category_id\":1050206001,\"category_name\":\"悬疑脑洞\"},{\"category_id\":1050206002,\"category_name\":\"灵异恐怖\"},{\"category_id\":1050206003,\"category_name\":\"风水奇幻\"},{\"category_id\":1050206004,\"category_name\":\"规则怪谈\"},{\"category_id\":1050206005,\"category_name\":\"克苏鲁\"},{\"category_id\":1050206006,\"category_name\":\"探案推理\"}]},{\"category_name\":\"游戏竞技\",\"categories\":[{\"category_id\":1050207001,\"category_name\":\"体育运动\"},{\"category_id\":1050207002,\"category_name\":\"电子竞技\"},{\"category_id\":1050207003,\"category_name\":\"奇幻网游\"},{\"category_id\":1050207004,\"category_name\":\"虚拟现实\"}]},{\"category_name\":\"轻小说\",\"categories\":[{\"category_id\":1050208001,\"category_name\":\"勇者魔王\"},{\"category_id\":1050208002,\"category_name\":\"魔法异能\"},{\"category_id\":1050208003,\"category_name\":\"恋爱日常\"},{\"category_id\":1050208004,\"category_name\":\"IP改编\"},{\"category_id\":1050208005,\"category_name\":\"搞笑脑洞\"}]},{\"category_name\":\"言情\",\"categories\":[{\"category_id\":1050209001,\"category_name\":\"仙侠言情\"},{\"category_id\":1050209002,\"category_name\":\"异世言情\"}]},{\"category_name\":\"同人耽美\",\"categories\":[{\"category_id\":1050210001,\"category_name\":\"影视同人\"},{\"category_id\":1050210002,\"category_name\":\"游戏同人\"},{\"category_id\":1050210003,\"category_name\":\"小说同人\"},{\"category_id\":1050210004,\"category_name\":\"动漫同人\"}]},{\"category_name\":\"名著经典\",\"categories\":[{\"category_id\":1050211001,\"category_name\":\"中国古典名著\"},{\"category_id\":1050211002,\"category_name\":\"中国近代名著\"},{\"category_id\":1050211003,\"category_name\":\"外国名著\"},{\"category_id\":1050211004,\"category_name\":\"国学研究\"}]},{\"category_name\":\"经济管理\",\"categories\":[{\"category_id\":1050212001,\"category_name\":\"金融财经\"},{\"category_id\":1050212002,\"category_name\":\"商业管理\"},{\"category_id\":1050212003,\"category_name\":\"理财投资\"},{\"category_id\":1050212004,\"category_name\":\"其他\"}]},{\"category_name\":\"成长励志\",\"categories\":[{\"category_id\":1050213001,\"category_name\":\"心灵治愈\"},{\"category_id\":1050213002,\"category_name\":\"人际交往\"}]},{\"category_name\":\"人文社科\",\"categories\":[{\"category_id\":1050214001,\"category_name\":\"历史\"},{\"category_id\":1050214002,\"category_name\":\"心理学\"},{\"category_id\":1050214003,\"category_name\":\"宗教\"},{\"category_id\":1050214004,\"category_name\":\"哲学\"},{\"category_id\":1050214005,\"category_name\":\"社会科学\"}]},{\"category_name\":\"生活\",\"categories\":[{\"category_id\":1050215001,\"category_name\":\"时尚娱乐\"},{\"category_id\":1050215002,\"category_name\":\"休闲旅游\"},{\"category_id\":1050215003,\"category_name\":\"生活百科\"}]},{\"category_name\":\"文学艺术\",\"categories\":[{\"category_id\":1050216001,\"category_name\":\"传记\"},{\"category_id\":1050216002,\"category_name\":\"艺术\"},{\"category_id\":1050216003,\"category_name\":\"纪实文学\"},{\"category_id\":1050216004,\"category_name\":\"诗歌散文\"},{\"category_id\":1050216005,\"category_name\":\"文学理论\"}]},{\"category_name\":\"科学科技\",\"categories\":[{\"category_id\":1050217001,\"category_name\":\"科普\"},{\"category_id\":1050217002,\"category_name\":\"医学\"},{\"category_id\":1050217003,\"category_name\":\"自然科学\"},{\"category_id\":1050217004,\"category_name\":\"科技应用\"},{\"category_id\":1050217005,\"category_name\":\"计算机与互联网\"}]},{\"category_name\":\"教育\",\"categories\":[{\"category_id\":1050218001,\"category_name\":\"成人教育\"},{\"category_id\":1050218002,\"category_name\":\"高中教育\"},{\"category_id\":1050218003,\"category_name\":\"初中教育\"},{\"category_id\":1050218004,\"category_name\":\"小学教育\"},{\"category_id\":1050218005,\"category_name\":\"学前教育\"},{\"category_id\":1050218006,\"category_name\":\"其他教育\"}]},{\"category_name\":\"少儿\",\"categories\":[{\"category_id\":1050219001,\"category_name\":\"漫画绘本\"},{\"category_id\":1050219002,\"category_name\":\"科普百科\"},{\"category_id\":1050219003,\"category_name\":\"儿童文学\"},{\"category_id\":1050219004,\"category_name\":\"英语\"},{\"category_id\":1050219005,\"category_name\":\"幼儿启蒙\"},{\"category_id\":1050219006,\"category_name\":\"婴儿读物\"},{\"category_id\":1050219007,\"category_name\":\"益智游戏\"},{\"category_id\":1050219008,\"category_name\":\"励志\"},{\"category_id\":1050219009,\"category_name\":\"学前教育\"}]},{\"category_name\":\"其他\",\"categories\":[{\"category_id\":1050220001,\"category_name\":\"其他\"}]}]},{\"category_name\":\"通信\",\"categories\":[{\"category_id\":1050301000,\"category_name\":\"手机卡\"},{\"category_name\":\"增值业务\",\"categories\":[{\"category_id\":1050302001,\"category_name\":\"流量包\"},{\"category_id\":1050302002,\"category_name\":\"会员权益包\"},{\"category_id\":1050302003,\"category_name\":\"彩铃\"},{\"category_id\":1050302004,\"category_name\":\"其他\"}]},{\"category_name\":\"通信设备\",\"categories\":[{\"category_id\":1050303001,\"category_name\":\"无线wifi\"},{\"category_id\":1050303002,\"category_name\":\"投影仪\"},{\"category_id\":1050303003,\"category_name\":\"其他\"}]},{\"category_id\":1050304000,\"category_name\":\"宽带\"}]},{\"category_name\":\"工具\",\"categories\":[{\"category_name\":\"旅游出行\",\"categories\":[{\"category_id\":1050401001,\"category_name\":\"地图导航\"},{\"category_id\":1050401002,\"category_name\":\"公交地铁\"},{\"category_id\":1050401003,\"category_name\":\"共享单车\"},{\"category_id\":1050401004,\"category_name\":\"航班服务\"},{\"category_id\":1050401005,\"category_name\":\"火车服务\"},{\"category_id\":1050401006,\"category_name\":\"酒店服务\"},{\"category_id\":1050401007,\"category_name\":\"旅游攻略\"},{\"category_id\":1050401008,\"category_name\":\"民宿短租\"},{\"category_id\":1050401009,\"category_name\":\"在线旅游\"},{\"category_id\":1050401010,\"category_name\":\"车主服务\"},{\"category_id\":1050401011,\"category_name\":\"驾照考试\"},{\"category_id\":1050401012,\"category_name\":\"违章查询\"},{\"category_id\":1050401013,\"category_name\":\"车辆租用\"},{\"category_id\":1050401014,\"category_name\":\"其他\"},{\"category_id\":1050401015,\"category_name\":\"走路记步\"}]},{\"category_name\":\"效率提升\",\"categories\":[{\"category_id\":1050402001,\"category_name\":\"通讯辅助\"},{\"category_id\":1050402002,\"category_name\":\"星座运势\"},{\"category_id\":1050402003,\"category_name\":\"桌面组件\"},{\"category_id\":1050402004,\"category_name\":\"放大镜\"},{\"category_id\":1050402005,\"category_name\":\"条形扫码\"},{\"category_id\":1050402006,\"category_name\":\"WiFi\"},{\"category_id\":1050402007,\"category_name\":\"浏览器\"},{\"category_id\":1050402008,\"category_name\":\"输入法\"},{\"category_id\":1050402009,\"category_name\":\"搜索下载\"},{\"category_id\":1050402010,\"category_name\":\"文件传输\"},{\"category_id\":1050402011,\"category_name\":\"文件管理\"},{\"category_id\":1050402012,\"category_name\":\"应用商店\"},{\"category_id\":1050402013,\"category_name\":\"语音助手\"},{\"category_id\":1050402014,\"category_name\":\"手机壁纸\"},{\"category_id\":1050402015,\"category_name\":\"头像表情\"},{\"category_id\":1050402016,\"category_name\":\"桌面主题\"},{\"category_id\":1050402017,\"category_name\":\"计算器\"},{\"category_id\":1050402018,\"category_name\":\"时间闹钟\"},{\"category_id\":1050402019,\"category_name\":\"手电筒\"},{\"category_id\":1050402020,\"category_name\":\"遥控器\"},{\"category_id\":1050402021,\"category_name\":\"手机铃声\"},{\"category_id\":1050402022,\"category_name\":\"手机锁屏\"},{\"category_id\":1050402023,\"category_name\":\"AI/GPT\"},{\"category_id\":1050402024,\"category_name\":\"充电\"},{\"category_id\":1050402025,\"category_name\":\"扫描\"},{\"category_id\":1050402026,\"category_name\":\"来电秀\"},{\"category_id\":1050402027,\"category_name\":\"综合资讯\"},{\"category_id\":1050402028,\"category_name\":\"记账\"},{\"category_id\":1050402029,\"category_name\":\"网络电话-通话\"},{\"category_id\":1050402030,\"category_name\":\"省电/安全/优化\"},{\"category_id\":1050402031,\"category_name\":\"字体美化/大字版\"},{\"category_id\":1050402032,\"category_name\":\"天气/日历\"}]},{\"category_name\":\"运动健康\",\"categories\":[{\"category_id\":1050403001,\"category_name\":\"减肥瘦身\"},{\"category_id\":1050403002,\"category_name\":\"健康管理\"},{\"category_id\":1050403003,\"category_name\":\"丽人美妆\"},{\"category_id\":1050403004,\"category_name\":\"医疗美容\"},{\"category_id\":1050403005,\"category_name\":\"运动健身\"},{\"category_id\":1050403006,\"category_name\":\"问诊咨询\"},{\"category_id\":1050403007,\"category_name\":\"医药服务\"},{\"category_id\":1050403008,\"category_name\":\"预约挂号\"},{\"category_id\":1050403009,\"category_name\":\"经期健康\"},{\"category_id\":1050403010,\"category_name\":\"孕育健康\"},{\"category_id\":1050403011,\"category_name\":\"育儿工具\"},{\"category_id\":1050403012,\"category_name\":\"育儿社区\"},{\"category_id\":1050403013,\"category_name\":\"冥想\"},{\"category_id\":1050403014,\"category_name\":\"其他\"}]},{\"category_name\":\"教育学习（教育）\",\"categories\":[{\"category_id\":1050404001,\"category_name\":\"K12\"},{\"category_id\":1050404002,\"category_name\":\"高等教育\"},{\"category_id\":1050404003,\"category_name\":\"教育工具\"},{\"category_id\":1050404004,\"category_name\":\"学前工具\"},{\"category_id\":1050404005,\"category_name\":\"语言学习\"},{\"category_id\":1050404006,\"category_name\":\"职业教育\"},{\"category_id\":1050404007,\"category_name\":\"翻译\"},{\"category_id\":1050404008,\"category_name\":\"其他\"}]},{\"category_name\":\"生活休闲\",\"categories\":[{\"category_id\":1050405001,\"category_name\":\"房屋租赁\"},{\"category_id\":1050405002,\"category_name\":\"装修服务\"},{\"category_id\":1050405003,\"category_name\":\"本地生活\"},{\"category_id\":1050405004,\"category_name\":\"餐厅推荐\"},{\"category_id\":1050405005,\"category_name\":\"电影演出\"},{\"category_id\":1050405006,\"category_name\":\"分类信息\"},{\"category_id\":1050405007,\"category_name\":\"家政服务\"},{\"category_id\":1050405008,\"category_name\":\"快递物流\"},{\"category_id\":1050405009,\"category_name\":\"美食菜谱\"},{\"category_id\":1050405010,\"category_name\":\"求职招聘\"},{\"category_id\":1050405011,\"category_name\":\"外卖服务\"},{\"category_id\":1050405012,\"category_name\":\"运营商服务\"},{\"category_id\":1050405013,\"category_name\":\"红包\"},{\"category_id\":1050405014,\"category_name\":\"潮玩\"},{\"category_id\":1050405015,\"category_name\":\"其他\"}]},{\"category_name\":\"视频\",\"categories\":[{\"category_id\":1050406001,\"category_name\":\"VR视频\"},{\"category_id\":1050406002,\"category_name\":\"电视直播\"},{\"category_id\":1050406003,\"category_name\":\"短视频\"},{\"category_id\":1050406004,\"category_name\":\"综合视频\"},{\"category_id\":1050406005,\"category_name\":\"视频播放器\"},{\"category_id\":1050406006,\"category_name\":\"视频工具\"},{\"category_id\":1050406007,\"category_name\":\"游戏直播\"},{\"category_id\":1050406008,\"category_name\":\"娱乐直播\"},{\"category_id\":1050406009,\"category_name\":\"在线视频\"},{\"category_id\":1050406010,\"category_name\":\"其他\"}]},{\"category_name\":\"摄影图像\",\"categories\":[{\"category_id\":1050407001,\"category_name\":\"拍照摄影\"},{\"category_id\":1050407002,\"category_name\":\"图片分享\"},{\"category_id\":1050407003,\"category_name\":\"图片美化\"},{\"category_id\":1050407004,\"category_name\":\"相册图库\"},{\"category_id\":1050407005,\"category_name\":\"其他\"}]},{\"category_name\":\"音乐\",\"categories\":[{\"category_id\":1050408001,\"category_name\":\"网络K歌\"},{\"category_id\":1050408002,\"category_name\":\"在线音乐\"},{\"category_id\":1050408003,\"category_name\":\"音乐播放器\"},{\"category_id\":1050408004,\"category_name\":\"音乐乐器\"},{\"category_id\":1050408005,\"category_name\":\"音乐识别\"},{\"category_id\":1050408006,\"category_name\":\"其他\"}]},{\"category_name\":\"资讯\",\"categories\":[{\"category_id\":1050409001,\"category_name\":\"财经资讯\"},{\"category_id\":1050409002,\"category_name\":\"军事资讯\"},{\"category_id\":1050409003,\"category_name\":\"科技资讯\"},{\"category_id\":1050409004,\"category_name\":\"体育资讯\"},{\"category_id\":1050409005,\"category_name\":\"娱乐资讯\"},{\"category_id\":1050409006,\"category_name\":\"杂志报纸\"},{\"category_id\":1050409007,\"category_name\":\"综合资讯\"},{\"category_id\":1050409008,\"category_name\":\"汽车资讯\"},{\"category_id\":1050409009,\"category_name\":\"企业/商业咨询\"},{\"category_id\":1050409010,\"category_name\":\"其他\"}]}]},{\"category_name\":\"社交\",\"categories\":[{\"category_name\":\"婚恋交友\",\"categories\":[{\"category_id\":1050501001,\"category_name\":\"即时通讯\"},{\"category_id\":1050501002,\"category_name\":\"情侣互动\"},{\"category_id\":1050501003,\"category_name\":\"社区交友\"},{\"category_id\":1050501004,\"category_name\":\"同性交友\"},{\"category_id\":1050501005,\"category_name\":\"下沉交友\"},{\"category_id\":1050501006,\"category_name\":\"传统婚恋\"},{\"category_id\":1050501007,\"category_name\":\"轻婚恋\"}]},{\"category_name\":\"语音交友\",\"categories\":[{\"category_id\":1050502001,\"category_name\":\"语音交友/陪玩\"}]},{\"category_name\":\"群聊社交\",\"categories\":[{\"category_id\":1050503001,\"category_name\":\"论坛贴吧\"},{\"category_id\":1050503002,\"category_name\":\"微博社交\"},{\"category_id\":1050503003,\"category_name\":\"其他\"},{\"category_id\":1050503004,\"category_name\":\"加粉返利\"},{\"category_id\":1050503005,\"category_name\":\"加粉捡漏\"},{\"category_id\":1050503006,\"category_name\":\"加粉券包\"}]}]},{\"category_name\":\"道具\",\"categories\":[{\"category_name\":\"装备道具\",\"categories\":[{\"category_id\":1050601001,\"category_name\":\"装扮型道具（皮肤外观等）\"},{\"category_id\":1050601002,\"category_name\":\"装备型道具（武器道具等）\"},{\"category_id\":1050601003,\"category_name\":\"消耗品道具（药品材料、爱心荣誉等）\"},{\"category_id\":1050601004,\"category_name\":\"其他\"}]},{\"category_name\":\"游戏货币\",\"categories\":[{\"category_id\":1050602001,\"category_name\":\"代金券\"},{\"category_id\":1050602002,\"category_name\":\"钻石\"},{\"category_id\":1050602003,\"category_name\":\"金币\"},{\"category_id\":1050602004,\"category_name\":\"其他\"}]},{\"category_name\":\"礼包卡券\",\"categories\":[{\"category_id\":1050603001,\"category_name\":\"抽卡道具\"},{\"category_id\":1050603002,\"category_name\":\"节日礼包\"},{\"category_id\":1050603003,\"category_name\":\"体验卡\"},{\"category_id\":1050603004,\"category_name\":\"碎片\"},{\"category_id\":1050603005,\"category_name\":\"其他\"}]},{\"category_name\":\"游戏服务\",\"categories\":[{\"category_id\":1050604001,\"category_name\":\"点卡\"},{\"category_id\":1050604002,\"category_name\":\"其他\"}]},{\"category_name\":\"其他\",\"categories\":[{\"category_id\":1050605001,\"category_name\":\"周边产品\"},{\"category_id\":1050605002,\"category_name\":\"其他\"}]}]},{\"category_id\":1050700000,\"category_name\":\"其他\"}]}";
            JSONObject jsonObject = JSONObject.parseObject(jsonStr);
            return R.ok(jsonObject);
        } else if (type == 2) {
            String jsonStr = "{\"category_name\":\"小程序\",\"categories\":[{\"category_name\":\"短剧\",\"categories\":[{\"category_name\":\"都市\",\"categories\":[{\"category_id\":1030101001,\"category_name\":\"神医\"},{\"category_id\":1030101002,\"category_name\":\"赘婿\"},{\"category_id\":1030101003,\"category_name\":\"鉴宝\"},{\"category_id\":1030101004,\"category_name\":\"战神\"},{\"category_id\":1030101005,\"category_name\":\"神豪\"},{\"category_id\":1030101006,\"category_name\":\"系统\"},{\"category_id\":1030101007,\"category_name\":\"校园\"},{\"category_id\":1030101008,\"category_name\":\"职场\"},{\"category_id\":1030101009,\"category_name\":\"官场\"},{\"category_id\":1030101010,\"category_name\":\"家庭\"},{\"category_id\":1030101011,\"category_name\":\"乡村\"},{\"category_id\":1030101012,\"category_name\":\"异能\"},{\"category_id\":1030101013,\"category_name\":\"其他\"}]},{\"category_name\":\"悬疑\",\"categories\":[{\"category_id\":1030102001,\"category_name\":\"灵异\"},{\"category_id\":1030102002,\"category_name\":\"悬疑推理\"},{\"category_id\":1030102003,\"category_name\":\"其他\"}]},{\"category_name\":\"现言\",\"categories\":[{\"category_id\":1030103001,\"category_name\":\"虐恋\"},{\"category_id\":1030103002,\"category_name\":\"甜宠\"},{\"category_id\":1030103003,\"category_name\":\"萌宝\"},{\"category_id\":1030103004,\"category_name\":\"总裁\"},{\"category_id\":1030103005,\"category_name\":\"腹黑\"},{\"category_id\":1030103006,\"category_name\":\"替身\"},{\"category_id\":1030103007,\"category_name\":\"娱乐明星\"},{\"category_id\":1030103008,\"category_name\":\"其他\"}]},{\"category_name\":\"古言\",\"categories\":[{\"category_id\":1030104001,\"category_name\":\"宫斗宅斗\"},{\"category_id\":1030104002,\"category_name\":\"种田经商\"},{\"category_id\":1030104003,\"category_name\":\"穿越\"},{\"category_id\":1030104004,\"category_name\":\"战争\"},{\"category_id\":1030104005,\"category_name\":\"其他\"}]},{\"category_name\":\"军事\",\"categories\":[{\"category_id\":1030105001,\"category_name\":\"穿越战争\"},{\"category_id\":1030105002,\"category_name\":\"现代军事\"},{\"category_id\":1030105003,\"category_name\":\"其他\"}]},{\"category_name\":\"玄幻\",\"categories\":[{\"category_id\":1030106001,\"category_name\":\"奇幻仙侠\"},{\"category_id\":1030106002,\"category_name\":\"科幻脑洞\"},{\"category_id\":1030106003,\"category_name\":\"架空玄幻\"},{\"category_id\":1030106004,\"category_name\":\"其他\"}]},{\"category_name\":\"其他剧情\",\"categories\":[{\"category_id\":1030107001,\"category_name\":\"其他\"}]}]},{\"category_name\":\"小说\",\"categories\":[{\"category_name\":\"奇幻玄幻\",\"categories\":[{\"category_id\":1030201001,\"category_name\":\"异世冒险\"},{\"category_id\":1030201002,\"category_name\":\"西方奇幻\"},{\"category_id\":1030201003,\"category_name\":\"东方玄幻\"},{\"category_id\":1030201004,\"category_name\":\"魔法异能\"}]},{\"category_name\":\"武侠仙侠\",\"categories\":[{\"category_id\":1030202001,\"category_name\":\"武侠江湖\"},{\"category_id\":1030202002,\"category_name\":\"仙侠修真\"},{\"category_id\":1030202003,\"category_name\":\"洪荒封神\"},{\"category_id\":1030202004,\"category_name\":\"脑洞修仙\"},{\"category_id\":1030202005,\"category_name\":\"长生\"}]},{\"category_name\":\"历史军事\",\"categories\":[{\"category_id\":1030203001,\"category_name\":\"历史架空\"},{\"category_id\":1030203002,\"category_name\":\"历史传记\"},{\"category_id\":1030203003,\"category_name\":\"历史穿越\"},{\"category_id\":1030203004,\"category_name\":\"谍战\"}]},{\"category_name\":\"都市社会\",\"categories\":[{\"category_id\":1030204001,\"category_name\":\"都市职场\"},{\"category_id\":1030204002,\"category_name\":\"影视娱乐\"},{\"category_id\":1030204003,\"category_name\":\"青春校园\"},{\"category_id\":1030204004,\"category_name\":\"都市生活\"},{\"category_id\":1030204005,\"category_name\":\"都市异能\"},{\"category_id\":1030204006,\"category_name\":\"种田萌娃\"},{\"category_id\":1030204007,\"category_name\":\"家庭伦理\"}]},{\"category_name\":\"科幻末世\",\"categories\":[{\"category_id\":1030205001,\"category_name\":\"末世求生\"},{\"category_id\":1030205002,\"category_name\":\"未来文明\"},{\"category_id\":1030205003,\"category_name\":\"赛博朋克\"},{\"category_id\":1030205004,\"category_name\":\"机甲星际\"},{\"category_id\":1030205005,\"category_name\":\"平行世界\"},{\"category_id\":1030205006,\"category_name\":\"异类接触\"}]},{\"category_name\":\"灵异悬疑\",\"categories\":[{\"category_id\":1030206001,\"category_name\":\"悬疑脑洞\"},{\"category_id\":1030206002,\"category_name\":\"灵异恐怖\"},{\"category_id\":1030206003,\"category_name\":\"风水奇幻\"},{\"category_id\":1030206004,\"category_name\":\"规则怪谈\"},{\"category_id\":1030206005,\"category_name\":\"克苏鲁\"},{\"category_id\":1030206006,\"category_name\":\"探案推理\"}]},{\"category_name\":\"游戏竞技\",\"categories\":[{\"category_id\":1030207001,\"category_name\":\"体育运动\"},{\"category_id\":1030207002,\"category_name\":\"电子竞技\"},{\"category_id\":1030207003,\"category_name\":\"奇幻网游\"},{\"category_id\":1030207004,\"category_name\":\"虚拟现实\"}]},{\"category_name\":\"轻小说\",\"categories\":[{\"category_id\":1030208001,\"category_name\":\"勇者魔王\"},{\"category_id\":1030208002,\"category_name\":\"魔法异能\"},{\"category_id\":1030208003,\"category_name\":\"恋爱日常\"},{\"category_id\":1030208004,\"category_name\":\"IP改编\"},{\"category_id\":1030208005,\"category_name\":\"搞笑脑洞\"}]},{\"category_name\":\"言情\",\"categories\":[{\"category_id\":1030209001,\"category_name\":\"仙侠言情\"},{\"category_id\":1030209002,\"category_name\":\"异世言情\"}]},{\"category_name\":\"同人耽美\",\"categories\":[{\"category_id\":1030210001,\"category_name\":\"影视同人\"},{\"category_id\":1030210002,\"category_name\":\"游戏同人\"},{\"category_id\":1030210003,\"category_name\":\"小说同人\"},{\"category_id\":1030210004,\"category_name\":\"动漫同人\"}]},{\"category_name\":\"名著经典\",\"categories\":[{\"category_id\":1030211001,\"category_name\":\"中国古典名著\"},{\"category_id\":1030211002,\"category_name\":\"中国近代名著\"},{\"category_id\":1030211003,\"category_name\":\"外国名著\"},{\"category_id\":1030211004,\"category_name\":\"国学研究\"}]},{\"category_name\":\"经济管理\",\"categories\":[{\"category_id\":1030212001,\"category_name\":\"金融财经\"},{\"category_id\":1030212002,\"category_name\":\"商业管理\"},{\"category_id\":1030212003,\"category_name\":\"理财投资\"},{\"category_id\":1030212004,\"category_name\":\"其他\"}]},{\"category_name\":\"成长励志\",\"categories\":[{\"category_id\":1030213001,\"category_name\":\"心灵治愈\"},{\"category_id\":1030213002,\"category_name\":\"人际交往\"}]},{\"category_name\":\"人文社科\",\"categories\":[{\"category_id\":1030214001,\"category_name\":\"历史\"},{\"category_id\":1030214002,\"category_name\":\"心理学\"},{\"category_id\":1030214003,\"category_name\":\"宗教\"},{\"category_id\":1030214004,\"category_name\":\"哲学\"},{\"category_id\":1030214005,\"category_name\":\"社会科学\"}]},{\"category_name\":\"生活\",\"categories\":[{\"category_id\":1030215001,\"category_name\":\"时尚娱乐\"},{\"category_id\":1030215002,\"category_name\":\"休闲旅游\"},{\"category_id\":1030215003,\"category_name\":\"生活百科\"}]},{\"category_name\":\"文学艺术\",\"categories\":[{\"category_id\":1030216001,\"category_name\":\"传记\"},{\"category_id\":1030216002,\"category_name\":\"艺术\"},{\"category_id\":1030216003,\"category_name\":\"纪实文学\"},{\"category_id\":1030216004,\"category_name\":\"诗歌散文\"},{\"category_id\":1030216005,\"category_name\":\"文学理论\"}]},{\"category_name\":\"科学科技\",\"categories\":[{\"category_id\":1030217001,\"category_name\":\"科普\"},{\"category_id\":1030217002,\"category_name\":\"医学\"},{\"category_id\":1030217003,\"category_name\":\"自然科学\"},{\"category_id\":1030217004,\"category_name\":\"科技应用\"},{\"category_id\":1030217005,\"category_name\":\"计算机与互联网\"}]},{\"category_name\":\"教育\",\"categories\":[{\"category_id\":1030218001,\"category_name\":\"成人教育\"},{\"category_id\":1030218002,\"category_name\":\"高中教育\"},{\"category_id\":1030218003,\"category_name\":\"初中教育\"},{\"category_id\":1030218004,\"category_name\":\"小学教育\"},{\"category_id\":1030218005,\"category_name\":\"学前教育\"},{\"category_id\":1030218006,\"category_name\":\"其他教育\"}]},{\"category_name\":\"少儿\",\"categories\":[{\"category_id\":1030219001,\"category_name\":\"漫画绘本\"},{\"category_id\":1030219002,\"category_name\":\"科普百科\"},{\"category_id\":1030219003,\"category_name\":\"儿童文学\"},{\"category_id\":1030219004,\"category_name\":\"英语\"},{\"category_id\":1030219005,\"category_name\":\"幼儿启蒙\"},{\"category_id\":1030219006,\"category_name\":\"婴儿读物\"},{\"category_id\":1030219007,\"category_name\":\"益智游戏\"},{\"category_id\":1030219008,\"category_name\":\"励志\"},{\"category_id\":1030219009,\"category_name\":\"学前教育\"}]},{\"category_name\":\"其他\",\"categories\":[{\"category_id\":1030220001,\"category_name\":\"其他\"}]}]},{\"category_name\":\"通信\",\"categories\":[{\"category_id\":1030301000,\"category_name\":\"手机卡\"},{\"category_name\":\"增值业务\",\"categories\":[{\"category_id\":1030302001,\"category_name\":\"流量包\"},{\"category_id\":1030302002,\"category_name\":\"会员权益包\"},{\"category_id\":1030302003,\"category_name\":\"彩铃\"},{\"category_id\":1030302004,\"category_name\":\"其他\"}]},{\"category_name\":\"通信设备\",\"categories\":[{\"category_id\":1030303001,\"category_name\":\"无线wifi\"},{\"category_id\":1030303002,\"category_name\":\"投影仪\"},{\"category_id\":1030303003,\"category_name\":\"其他\"}]},{\"category_id\":1030304000,\"category_name\":\"宽带\"}]},{\"category_name\":\"工具\",\"categories\":[{\"category_name\":\"旅游出行\",\"categories\":[{\"category_id\":1030401001,\"category_name\":\"地图导航\"},{\"category_id\":1030401002,\"category_name\":\"公交地铁\"},{\"category_id\":1030401003,\"category_name\":\"共享单车\"},{\"category_id\":1030401004,\"category_name\":\"航班服务\"},{\"category_id\":1030401005,\"category_name\":\"火车服务\"},{\"category_id\":1030401006,\"category_name\":\"酒店服务\"},{\"category_id\":1030401007,\"category_name\":\"旅游攻略\"},{\"category_id\":1030401008,\"category_name\":\"民宿短租\"},{\"category_id\":1030401009,\"category_name\":\"在线旅游\"},{\"category_id\":1030401010,\"category_name\":\"车主服务\"},{\"category_id\":1030401011,\"category_name\":\"驾照考试\"},{\"category_id\":1030401012,\"category_name\":\"违章查询\"},{\"category_id\":1030401013,\"category_name\":\"车辆租用\"},{\"category_id\":1030401014,\"category_name\":\"其他\"},{\"category_id\":1030401015,\"category_name\":\"走路记步\"}]},{\"category_name\":\"效率提升\",\"categories\":[{\"category_id\":1030402001,\"category_name\":\"通讯辅助\"},{\"category_id\":1030402002,\"category_name\":\"星座运势\"},{\"category_id\":1030402003,\"category_name\":\"桌面组件\"},{\"category_id\":1030402004,\"category_name\":\"放大镜\"},{\"category_id\":1030402005,\"category_name\":\"条形扫码\"},{\"category_id\":1030402006,\"category_name\":\"WiFi\"},{\"category_id\":1030402007,\"category_name\":\"浏览器\"},{\"category_id\":1030402008,\"category_name\":\"输入法\"},{\"category_id\":1030402009,\"category_name\":\"搜索下载\"},{\"category_id\":1030402010,\"category_name\":\"文件传输\"},{\"category_id\":1030402011,\"category_name\":\"文件管理\"},{\"category_id\":1030402012,\"category_name\":\"应用商店\"},{\"category_id\":1030402013,\"category_name\":\"语音助手\"},{\"category_id\":1030402014,\"category_name\":\"手机壁纸\"},{\"category_id\":1030402015,\"category_name\":\"头像表情\"},{\"category_id\":1030402016,\"category_name\":\"桌面主题\"},{\"category_id\":1030402017,\"category_name\":\"计算器\"},{\"category_id\":1030402018,\"category_name\":\"时间闹钟\"},{\"category_id\":1030402019,\"category_name\":\"手电筒\"},{\"category_id\":1030402020,\"category_name\":\"遥控器\"},{\"category_id\":1030402021,\"category_name\":\"手机铃声\"},{\"category_id\":1030402022,\"category_name\":\"手机锁屏\"},{\"category_id\":1030402023,\"category_name\":\"AI/GPT\"},{\"category_id\":1030402024,\"category_name\":\"充电\"},{\"category_id\":1030402025,\"category_name\":\"扫描\"},{\"category_id\":1030402026,\"category_name\":\"来电秀\"},{\"category_id\":1030402027,\"category_name\":\"综合资讯\"},{\"category_id\":1030402028,\"category_name\":\"记账\"},{\"category_id\":1030402029,\"category_name\":\"网络电话-通话\"},{\"category_id\":1030402030,\"category_name\":\"省电/安全/优化\"},{\"category_id\":1030402031,\"category_name\":\"字体美化/大字版\"},{\"category_id\":1030402032,\"category_name\":\"天气/日历\"}]},{\"category_name\":\"运动健康\",\"categories\":[{\"category_id\":1030403001,\"category_name\":\"减肥瘦身\"},{\"category_id\":1030403002,\"category_name\":\"健康管理\"},{\"category_id\":1030403003,\"category_name\":\"丽人美妆\"},{\"category_id\":1030403004,\"category_name\":\"医疗美容\"},{\"category_id\":1030403005,\"category_name\":\"运动健身\"},{\"category_id\":1030403006,\"category_name\":\"问诊咨询\"},{\"category_id\":1030403007,\"category_name\":\"医药服务\"},{\"category_id\":1030403008,\"category_name\":\"预约挂号\"},{\"category_id\":1030403009,\"category_name\":\"经期健康\"},{\"category_id\":1030403010,\"category_name\":\"孕育健康\"},{\"category_id\":1030403011,\"category_name\":\"育儿工具\"},{\"category_id\":1030403012,\"category_name\":\"育儿社区\"},{\"category_id\":1030403013,\"category_name\":\"冥想\"},{\"category_id\":1030403014,\"category_name\":\"其他\"}]},{\"category_name\":\"教育学习（教育）\",\"categories\":[{\"category_id\":1030404001,\"category_name\":\"K12\"},{\"category_id\":1030404002,\"category_name\":\"高等教育\"},{\"category_id\":1030404003,\"category_name\":\"教育工具\"},{\"category_id\":1030404004,\"category_name\":\"学前工具\"},{\"category_id\":1030404005,\"category_name\":\"语言学习\"},{\"category_id\":1030404006,\"category_name\":\"职业教育\"},{\"category_id\":1030404007,\"category_name\":\"翻译\"},{\"category_id\":1030404008,\"category_name\":\"其他\"}]},{\"category_name\":\"生活休闲\",\"categories\":[{\"category_id\":1030405001,\"category_name\":\"房屋租赁\"},{\"category_id\":1030405002,\"category_name\":\"装修服务\"},{\"category_id\":1030405003,\"category_name\":\"本地生活\"},{\"category_id\":1030405004,\"category_name\":\"餐厅推荐\"},{\"category_id\":1030405005,\"category_name\":\"电影演出\"},{\"category_id\":1030405006,\"category_name\":\"分类信息\"},{\"category_id\":1030405007,\"category_name\":\"家政服务\"},{\"category_id\":1030405008,\"category_name\":\"快递物流\"},{\"category_id\":1030405009,\"category_name\":\"美食菜谱\"},{\"category_id\":1030405010,\"category_name\":\"求职招聘\"},{\"category_id\":1030405011,\"category_name\":\"外卖服务\"},{\"category_id\":1030405012,\"category_name\":\"运营商服务\"},{\"category_id\":1030405013,\"category_name\":\"红包\"},{\"category_id\":1030405014,\"category_name\":\"潮玩\"},{\"category_id\":1030405015,\"category_name\":\"其他\"}]},{\"category_name\":\"视频\",\"categories\":[{\"category_id\":1030406001,\"category_name\":\"VR视频\"},{\"category_id\":1030406002,\"category_name\":\"电视直播\"},{\"category_id\":1030406003,\"category_name\":\"短视频\"},{\"category_id\":1030406004,\"category_name\":\"综合视频\"},{\"category_id\":1030406005,\"category_name\":\"视频播放器\"},{\"category_id\":1030406006,\"category_name\":\"视频工具\"},{\"category_id\":1030406007,\"category_name\":\"游戏直播\"},{\"category_id\":1030406008,\"category_name\":\"娱乐直播\"},{\"category_id\":1030406009,\"category_name\":\"在线视频\"},{\"category_id\":1030406010,\"category_name\":\"其他\"}]},{\"category_name\":\"摄影图像\",\"categories\":[{\"category_id\":1030407001,\"category_name\":\"拍照摄影\"},{\"category_id\":1030407002,\"category_name\":\"图片分享\"},{\"category_id\":1030407003,\"category_name\":\"图片美化\"},{\"category_id\":1030407004,\"category_name\":\"相册图库\"},{\"category_id\":1030407005,\"category_name\":\"其他\"}]},{\"category_name\":\"音乐\",\"categories\":[{\"category_id\":1030408001,\"category_name\":\"网络K歌\"},{\"category_id\":1030408002,\"category_name\":\"在线音乐\"},{\"category_id\":1030408003,\"category_name\":\"音乐播放器\"},{\"category_id\":1030408004,\"category_name\":\"音乐乐器\"},{\"category_id\":1030408005,\"category_name\":\"音乐识别\"},{\"category_id\":1030408006,\"category_name\":\"其他\"}]},{\"category_name\":\"资讯\",\"categories\":[{\"category_id\":1030409001,\"category_name\":\"财经资讯\"},{\"category_id\":1030409002,\"category_name\":\"军事资讯\"},{\"category_id\":1030409003,\"category_name\":\"科技资讯\"},{\"category_id\":1030409004,\"category_name\":\"体育资讯\"},{\"category_id\":1030409005,\"category_name\":\"娱乐资讯\"},{\"category_id\":1030409006,\"category_name\":\"杂志报纸\"},{\"category_id\":1030409007,\"category_name\":\"综合资讯\"},{\"category_id\":1030409008,\"category_name\":\"汽车资讯\"},{\"category_id\":1030409009,\"category_name\":\"企业/商业咨询\"},{\"category_id\":1030409010,\"category_name\":\"其他\"}]}]},{\"category_name\":\"社交\",\"categories\":[{\"category_name\":\"婚恋交友\",\"categories\":[{\"category_id\":1030501001,\"category_name\":\"即时通讯\"},{\"category_id\":1030501002,\"category_name\":\"情侣互动\"},{\"category_id\":1030501003,\"category_name\":\"社区交友\"},{\"category_id\":1030501004,\"category_name\":\"同性交友\"},{\"category_id\":1030501005,\"category_name\":\"下沉交友\"},{\"category_id\":1030501006,\"category_name\":\"传统婚恋\"},{\"category_id\":1030501007,\"category_name\":\"轻婚恋\"}]},{\"category_name\":\"语音交友\",\"categories\":[{\"category_id\":1030502001,\"category_name\":\"语音交友/陪玩\"}]},{\"category_name\":\"群聊社交\",\"categories\":[{\"category_id\":1030503001,\"category_name\":\"论坛贴吧\"},{\"category_id\":1030503002,\"category_name\":\"微博社交\"},{\"category_id\":1030503003,\"category_name\":\"其他\"},{\"category_id\":1030503004,\"category_name\":\"加粉返利\"},{\"category_id\":1030503005,\"category_name\":\"加粉捡漏\"},{\"category_id\":1030503006,\"category_name\":\"加粉券包\"}]}]},{\"category_name\":\"道具\",\"categories\":[{\"category_name\":\"装备道具\",\"categories\":[{\"category_id\":1030601001,\"category_name\":\"装扮型道具（皮肤外观等）\"},{\"category_id\":1030601002,\"category_name\":\"装备型道具（武器道具等）\"},{\"category_id\":1030601003,\"category_name\":\"消耗品道具（药品材料、爱心荣誉等）\"},{\"category_id\":1030601004,\"category_name\":\"其他\"}]},{\"category_name\":\"游戏货币\",\"categories\":[{\"category_id\":1030602001,\"category_name\":\"代金券\"},{\"category_id\":1030602002,\"category_name\":\"钻石\"},{\"category_id\":1030602003,\"category_name\":\"金币\"},{\"category_id\":1030602004,\"category_name\":\"其他\"}]},{\"category_name\":\"礼包卡券\",\"categories\":[{\"category_id\":1030603001,\"category_name\":\"抽卡道具\"},{\"category_id\":1030603002,\"category_name\":\"节日礼包\"},{\"category_id\":1030603003,\"category_name\":\"体验卡\"},{\"category_id\":1030603004,\"category_name\":\"碎片\"},{\"category_id\":1030603005,\"category_name\":\"其他\"}]},{\"category_name\":\"游戏服务\",\"categories\":[{\"category_id\":1030604001,\"category_name\":\"点卡\"},{\"category_id\":1030604002,\"category_name\":\"其他\"}]},{\"category_name\":\"其他\",\"categories\":[{\"category_id\":1030605001,\"category_name\":\"周边产品\"},{\"category_id\":1030605002,\"category_name\":\"其他\"}]}]},{\"category_id\":1030700000,\"category_name\":\"其他\"}]}";
            JSONObject jsonObject = JSONObject.parseObject(jsonStr);
            return R.ok(jsonObject);
        }
        return R.fail();
    }

    /**
     * 创建字节小程序
     *
     * @param req
     * @return
     */
    @PostMapping("/createToolsMicroApp")
    public R createToolsMicroApp(@RequestBody @Validated CreateToolsMicroAppReq req) {
        req.checkParam();
        boolean isOk = oceMicroAppService.createToolsMicroApp(req.getAccountId().toString(), req);
        return R.isOk(isOk);
    }

    /**
     * 更新字节小程序
     *
     * @param req
     * @return
     */
    @PostMapping("/updateToolsMicroApp")
    public R updateToolsMicroApp(@RequestBody @Validated UpdateToolsMicroAppReq req) {
        req.checkParam();
        boolean isOk = oceMicroAppService.updateToolsMicroApp(req.getAccountId().toString(), req);
        return R.ok(isOk);
    }

    /**
     * 获取字节小程序
     *
     * @param
     * @return
     */
    @GetMapping("/queryToolsMicroApp")
    public R queryToolsMicroApp(GetToolsMicroAppListQo qo) {
        qo.checkParam();
        ToolsMicroAppListV30ResponseData isOk = oceanEngineThirdRemoteService.getToolsMicroAppList(qo);
        return R.ok(isOk);
    }

    /**
     * 获取字节小程序-添加资产时选择字节小程序
     *
     * @param
     * @return
     */
    @GetMapping("/queryToolsMicroAppNew")
    public R<List<ToolsMicroAppListV30ResponseDataListInner>> queryToolsMicroAppNew(GetToolsMicroAppListQo qo) {
        qo.checkParam();
        List<ToolsMicroAppListV30ResponseDataListInner> isOk = oceanEngineThirdRemoteService.queryToolsMicroAppNew(qo);
        return R.ok(isOk);
    }

    /**
     * 获取字节小程序详情内容（链接）
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1778265753535620?origin=left_nav
     *
     * @param
     * @return
     */
    @GetMapping("/queryToolsAssetLinkList")
    public R queryToolsAssetLinkList(GetToolsAssetLinkListPageQo qo) {
        qo.checkParam();
        ToolsAssetLinkListV30ResponseData isOk = oceanEngineThirdRemoteService.getToolsAssetLinkList(qo.getAccountId().toString(), qo);
        return R.ok(isOk);
    }

    /**
     * 设置小游戏&小程序共享
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1773089427219584?origin=left_nav
     *
     * @param
     * @return
     */
    @PostMapping("/bpAssetManagementShare")
    public R bpAssetManagementShare(@RequestBody ShareDpAssetManagementReq qo) {
        Boolean isOk = oceanEngineThirdRemoteService.shareDpAssetManagement(qo.getOrganizationId().toString(), qo);
        return R.isOk(isOk);
    }

    /**
     * 取消小游戏&小程序共享
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1773102677218368?origin=left_nav
     *
     * @param
     * @return
     */
    @PostMapping("/bpAssetManagementShareCancel")
    public R bpAssetManagementShareCancel(@RequestBody ShareDpAssetManagementReq qo) {
        boolean isOk = oceanEngineThirdRemoteService.cancelShareDpAssetManagement(qo.getOrganizationId().toString(), qo);
        return R.isOk(isOk);
    }

    /**
     * 查看小游戏/小程序共享范围
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1773105971421187?origin=left_nav
     *
     * @param
     * @return
     */
    @GetMapping("/queryBpAssetManagementShare")
    public TableDataInfo<ToolsBpAssetManagementShareGetV30ResponseDataSharedAccountsInner> queryBpAssetManagementShare(@RequestParam Long accountId, @RequestParam Long instanceId, @RequestParam ToolsBpAssetManagementShareGetV30AssetType assetType) {
        ToolsBpAssetManagementShareGetV30ResponseData page = oceanEngineThirdRemoteService.getShareDpAssetManagement(accountId.toString(), instanceId, assetType);

        TableDataInfo<ToolsBpAssetManagementShareGetV30ResponseDataSharedAccountsInner> respData = new TableDataInfo<>();
        respData.setCode(HttpStatus.HTTP_OK);
        respData.setMsg("查询成功");
        respData.setRows(page.getSharedAccounts());
        respData.setTotal(page.getPageInfo().getTotalNumber());
        return respData;
    }

    /**
     * 创建微信小程序
     *
     * @param req
     * @return
     */
    @PostMapping("/createToolsWechatApplet")
    public R createToolsWechatApplet(@RequestBody @Validated CreateToolsWechatAppletReq req) {
        req.checkParam();
        boolean isOk = wechatAppService.createToolsWechatApplet(req.getAccountId(), req);
        return R.isOk(isOk);
    }

    /**
     * 获取微信小程序
     *
     * @param
     * @return
     */
    @GetMapping("/queryWechatApplet")
    public TableDataInfo<ToolsWechatAppletListV30ResponseDataListInner> queryWechatApplet(GetToolsWechatAppletListQo qo) {
        qo.checkParam();
        ToolsWechatAppletListV30ResponseData page = oceanEngineThirdRemoteService.getToolsWechatAppletList(qo);

        TableDataInfo<ToolsWechatAppletListV30ResponseDataListInner> respData = new TableDataInfo<>();
        respData.setCode(HttpStatus.HTTP_OK);
        respData.setMsg("查询成功");
        respData.setRows(page.getList());
        respData.setTotal(page.getPageInfo().getTotalNumber());
        return respData;
    }

    /**
     * 查询微信创建/共享的小程序
     * @param qo
     * @return
     */
    @GetMapping("/getAllWechatApplet")
    public R<List<ToolsWechatAppletListV30ResponseDataListInner>> getAllWechatApplet(GetToolsWechatAppletListQo qo){
        qo.checkParam();
        qo.setPageSize(100L);
        ToolsWechatAppletListV30ResponseData page = oceanEngineThirdRemoteService.getToolsWechatAppletList(qo);

        qo.setSearchType(ToolsWechatAppletListV30FilteringSearchType.SHARE_ONLY);
        ToolsWechatAppletListV30ResponseData page2 = oceanEngineThirdRemoteService.getToolsWechatAppletList(qo);

        List<ToolsWechatAppletListV30ResponseDataListInner> respList = new ArrayList<>();
        if(page.getList()!=null && page.getList().size()>0){
            respList.addAll(page.getList());
        }
        if(page2.getList()!=null && page2.getList().size()>0){
            respList.addAll(page2.getList());
        }
        return R.ok(respList);
    }

    /**
     * 获取账户下资产列表（新）
     * https://open.oceanengine.com/labels/34/docs/1800985709803914?origin=left_nav
     *
     * @param qo
     * @return
     */
    @GetMapping("/getEventAllAssetsList")
    public TableDataInfo<GetEventAllAssetsListVo> getEventAllAssetsList(GetEventAllAssetsListPageQo qo) {
        qo.checkParam();
        ToolsEventAllAssetsListV2ResponseData page = oceanEngineThirdRemoteService.getEventAllAssetsList(qo.getAccountId(), qo);

        List<Long> assetIds = page.getAssetList().stream().map(ToolsEventAllAssetsListV2ResponseDataAssetListInner::getAssetId).collect(Collectors.toList());

        Map<Long, ToolsEventAllAssetsDetailV2ResponseDataAssetListInner> map = new HashMap<>();
        if(assetIds.size()>0) {
            List<ToolsEventAllAssetsDetailV2ResponseDataAssetListInner> assetsDetailList = oceanEngineThirdRemoteService.getEventAllAssetsDetail(qo.getAccountId(), qo.getAdvertiserId(), assetIds);
            map = assetsDetailList.stream().collect(Collectors.toMap(item -> item.getAssetId(), item -> item));
        }

        List<GetEventAllAssetsListVo> respList = new ArrayList<>();
        for (ToolsEventAllAssetsListV2ResponseDataAssetListInner inner : page.getAssetList()) {
            GetEventAllAssetsListVo vo = BeanUtil.copyProperties(inner, GetEventAllAssetsListVo.class);
            ToolsEventAllAssetsDetailV2ResponseDataAssetListInner respDTO = map.get(inner.getAssetId());
            if(respDTO!=null) {
                vo.setMicroAppInstanceId(respDTO.getMicroAppInstanceId());
                vo.setMicroAppId(respDTO.getMicroAppId());
            }
            respList.add(vo);
        }

        TableDataInfo<GetEventAllAssetsListVo> respData = new TableDataInfo<>();
        respData.setCode(HttpStatus.HTTP_OK);
        respData.setMsg("查询成功");
        respData.setRows(respList);
        respData.setTotal(page.getPageInfo().getTotalNumber());
        return respData;
    }

    /**
     * 获取资产下已创建事件列表
     * https://open.oceanengine.com/labels/34/docs/1709793086075972?origin=left_nav
     *
     * @param qo
     * @return
     */
    @GetMapping("/getEventManagerConfigs")
    public R<List<EventManagerEventConfigsGetV2ResponseDataEventConfigsInner>> getEventManagerConfigs(GetEventManagerConfigsPageQo qo) {
        qo.checkParam();
        List<EventManagerEventConfigsGetV2ResponseDataEventConfigsInner> page = oceanEngineThirdRemoteService.getEventManagerConfigs(qo.getAccountId(), qo);
        return R.ok(page);
    }

    /**
     * 获取可创建事件列表
     * https://open.oceanengine.com/labels/34/docs/1709793059412996?origin=left_nav
     *
     * @param qo
     * @return
     */
    @GetMapping("/getEventManagerAvailableEventsList")
    public R<List<EventManagerAvailableEventsGetV2ResponseDataEventConfigsInner>> getEventManagerAvailableEventsList(GetEventManagerConfigsPageQo qo) {
        qo.checkParam();
        List<EventManagerAvailableEventsGetV2ResponseDataEventConfigsInner> page = oceanEngineThirdRemoteService.getEventManagerAvailableEventsList(qo.getAccountId(), qo.getAdvertiserId(), qo.getAssetId());
        return R.ok(page);
    }

    /**
     * 创建事件资产
     * https://open.oceanengine.com/labels/34/docs/1709792943937547?origin=left_nav
     *
     * @param req
     * @return
     */
    @PostMapping("/createEventManagerAssets")
    public R createEventManagerAssets(@RequestBody @Validated CreateEventManagerAssetsReq req) {
        req.checkParam();
        boolean isOk = oceanEngineThirdRemoteService.createEventManagerAssets(req.getAccountId(), req);
        return R.isOk(isOk);
    }

    /**
     * 资产下创建事件
     *
     * @param req
     * @return
     */
    @PostMapping("/createEventManagerEvents")
    public R createEventManagerEvents(@RequestBody @Validated CreateEventManagerEventsReq req) {
        req.checkParam();
        boolean isOk = oceanEngineThirdRemoteService.createEventManagerEvents(req);
        return R.isOk(isOk);
    }


    /**
     * 更新微信小程序
     *
     * @param req
     * @return
     */
    @PostMapping("/updateToolsWechatApplet")
    public R updateToolsWechatApplet(@RequestBody @Validated UpdateToolsWechatAppletReq req) {
        req.checkParam();
        boolean isOk = wechatAppService.updateToolsWechatApplet(req.getAccountId(), req);
        if (isOk) {
            return R.ok();
        }
        return R.fail();
    }

    /**
     * 获取视频素材
     * https://open.oceanengine.com/labels/34/docs/1696710601820172?origin=left_nav
     *
     * @param qo
     * @return
     */
    @GetMapping("/getVideoList")
    public TableDataInfo<FileVideoGetV2ResponseDataListInner> getVideoList(GetVideoListQo qo) {
        qo.checkParam();
        FileVideoGetV2ResponseData page = oceanEngineThirdRemoteService.getVideoList(qo);
        TableDataInfo<FileVideoGetV2ResponseDataListInner> respData = new TableDataInfo<>();
        respData.setCode(HttpStatus.HTTP_OK);
        respData.setMsg("查询成功");
        respData.setRows(page.getList());
        respData.setTotal(page.getPageInfo().getTotalNumber());
        return respData;
    }

    /**
     * 获取图片素材
     * https://open.oceanengine.com/labels/7/docs/1696710601254912?origin=left_nav
     * @param qo
     * @return
     */
    @GetMapping("/getImageList")
    public TableDataInfo<FileImageGetV2ResponseDataListInner> getImageList(GetImageListQo qo) {
        qo.checkParam();
        FileImageGetV2ResponseData page = oceanEngineThirdRemoteService.getImageList(qo);
        TableDataInfo<FileImageGetV2ResponseDataListInner> respData = new TableDataInfo<>();
        respData.setCode(HttpStatus.HTTP_OK);
        respData.setMsg("查询成功");
        respData.setRows(page.getList());
        respData.setTotal(page.getPageInfo().getTotalNumber());
        return respData;
    }

    /**
     * 获取视频素材评估标签（新版）
     * https://open.oceanengine.com/labels/34/docs/1789500809829388?origin=left_nav
     *
     * @param qo
     * @return
     */
    @GetMapping("/getMaterialAttributesDetail")
    @Deprecated
    public TableDataInfo<FileMaterialAttributesListV2ResponseDataMaterialsInner> getMaterialAttributesDetail(GetMaterialAttributesDetailQo qo) {
        FileMaterialAttributesListV2ResponseData page = oceanEngineThirdRemoteService.getMaterialAttributesDetail(qo);
        TableDataInfo<FileMaterialAttributesListV2ResponseDataMaterialsInner> respData = new TableDataInfo<>();
        respData.setCode(HttpStatus.HTTP_OK);
        respData.setMsg("查询成功");
        respData.setRows(page.getMaterials());
        respData.setTotal(page.getPage().getTotalNumber());
        return respData;
    }

    /**
     * 素材推送
     * 推送视频数＜=50、推送账户数*推送视频数＜=1000
     * https://open.oceanengine.com/labels/34/docs/1696710604852236?origin=left_nav
     *
     * @param req
     * @return
     */
    @PostMapping("/bindMaterial")
    public R bindMaterial(@RequestBody @Validated BindMaterialReq req) {
        req.checkParam();
        oceanEngineThirdRemoteService.bindMaterial(req);
        return R.ok();
    }


    /**
     * 创建橙子建站站点/落地页  cx
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1696710617712640?origin=left_nav
     *
     * @param req
     * @return
     */
    @PostMapping("/createToolsSite")
    public R createToolsSite(@RequestBody @Validated CreateToolsSiteCreateV2Request req) {
        req.checkParam();
        boolean isOk = oceanEngineThirdRemoteService.createToolsSite(req.getAccountId().toString(), req);
        return R.isOk(isOk);
    }

    /**
     * 修改橙子建站站点/落地页
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1696710618300431?origin=left_nav
     *
     * @param req
     * @return
     */
    @PostMapping("/updateToolsSite")
    public R updateToolsSite(@RequestBody @Validated UpdateToolsSiteCreateV2Request req) {
        boolean isOk = oceanEngineThirdRemoteService.updateToolsSite(req.getAccountId().toString(), req);
        return R.isOk(isOk);
    }

    /**
     * 更改橙子建站站点状态
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1696710618884096?origin=left_nav
     *
     * @param req
     * @return
     */
    @PostMapping("/updateStatusToolsSite")
    public R updateStatusToolsSite(@RequestBody @Validated UpdateStatusToolsSiteCreateV2Request req) {
        boolean isOk = oceanEngineThirdRemoteService.updateStatusToolsSite(req.getAccountId().toString(), req);
        return R.isOk(isOk);
    }

    /**
     * 获取橙子建站站点预览地址
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1696710619437056?origin=left_nav
     *
     * @param
     * @return
     */
    @GetMapping("/getToolsSitePreview")
    public R getToolsSitePreview(@RequestParam Long advertiserId, @RequestParam String accountId, @RequestParam String siteId) {
        ToolsSitePreviewV2Response isOk = oceanEngineThirdRemoteService.getToolsSitePreview(advertiserId, accountId, siteId);
        return R.ok(isOk);
    }

    /**
     * 获取橙子建站站点详细信息
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1696710620022799?origin=left_nav
     *
     * @param
     * @return
     */
    @GetMapping("/getToolsSiteRead")
    public R getToolsSiteRead(@RequestParam Long advertiserId, @RequestParam String accountId, @RequestParam String siteId) {
        ToolsSiteReadV2Response response = oceanEngineThirdRemoteService.getToolsSiteRead(advertiserId, accountId, siteId);
        return R.ok(response);
    }

    /**
     * 获取橙子建站站点列表
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1696710620579852?origin=left_nav
     *
     * @param
     * @return
     */
    @GetMapping("/getToolsSiteList")
    public TableDataInfo<OceSiteVo> getToolsSiteList(ToolsSiteListV2Request req) {
        ToolsSiteGetV2ResponseData page = oceanEngineThirdRemoteService.getToolsSiteList(req.getAccountId(), req);

        TableDataInfo<OceSiteVo> respData = new TableDataInfo<>();
        respData.setCode(HttpStatus.HTTP_OK);
        respData.setMsg("查询成功");
        respData.setRows(BeanUtil.copyToList(page.getList(),OceSiteVo.class));
        respData.setTotal(page.getPageInfo().getTotalNumber());
        return respData;
    }

    /**
     * 获取橙子建站站点列表(自建+分享的站点)
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1696710620579852?origin=left_nav
     * @param
     * @return
     */
    @GetMapping("/getAllToolsSiteList")
    public R<List<ToolsSiteGetV2ResponseDataListInner>> getAllToolsSiteList(ToolsSiteListV2Request req) {
        req.checkParam();
        req.setPageSize(300L);

        List<ToolsSiteGetV2ResponseDataListInner> respList = new ArrayList<>();
        ToolsSiteGetV2ResponseData page = oceanEngineThirdRemoteService.getToolsSiteList(req.getAccountId(), req);
        if(page.getList()!=null && page.getList().size()>0) {
            respList.addAll(page.getList());
        }

        req.setShareType(ToolsSiteGetV2ShareType.SHARE);
        ToolsSiteGetV2ResponseData page2 = oceanEngineThirdRemoteService.getToolsSiteList(req.getAccountId(), req);
        if(page2.getList()!=null && page2.getList().size()>0) {
            respList.addAll(page2.getList());
        }
        return R.ok(respList);
    }



    /**
     * 创建原生锚点-网服
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1757798123491403?origin=left_nav
     *
     * @param req
     * @return
     */
    @PostMapping("/createNativeAnchor")
    public R createNativeAnchor(@RequestBody @Validated CreateNativeAnchorV3Request req) {
        req.checkParam();
        req.urlFilter();
        boolean isOk = oceanEngineThirdRemoteService.createNativeAnchor(req.getAccountId().toString(), req);
        return R.isOk(isOk);
    }

    /**
     * 更新原生锚点-网服
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1780079786680328?origin=left_nav
     *
     * @param req
     * @return
     */
    @PostMapping("/updateNativeAnchor")
    public R updateNativeAnchor(@RequestBody @Validated UpdateNativeAnchorV3Request req) {
        req.checkParam();
        boolean isOk = oceanEngineThirdRemoteService.updateNativeAnchor(req.getAccountId().toString(), req);
        return R.isOk(isOk);
    }

    /**
     * 删除原生锚点-网服
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1780079261760524?origin=left_nav
     *
     * @param anchorId 原生锚点ID
     * @return
     */
    @GetMapping("/deleteNativeAnchor")
    public R deleteNativeAnchor(@RequestParam Long advertiserId, @RequestParam String accountId, @RequestParam String anchorId) {
        boolean isOk = oceanEngineThirdRemoteService.deleteNativeAnchor(accountId, advertiserId, anchorId);
        return R.isOk(isOk);
    }

    /**
     * 获取原生锚点列表
     * https://open.oceanengine.com/labels/34/docs/1757715831323652?origin=left_nav
     *
     * @param qo
     * @return
     */
    @GetMapping("/getNativeAnchor")
    public TableDataInfo<NativeAnchorGetV30ResponseDataListInner> getNativeAnchor(GetNativeAnchorV3Request qo) {
        qo.checkParam();
        NativeAnchorGetV30Response page = oceanEngineThirdRemoteService.getNativeAnchor(qo);
        TableDataInfo<NativeAnchorGetV30ResponseDataListInner> respData = new TableDataInfo<>();
        respData.setCode(HttpStatus.HTTP_OK);
        respData.setMsg("查询成功");
        respData.setRows(page.getData().getList());
        respData.setTotal(page.getData().getPageInfo().getTotalNumber());
        return respData;
    }

    /**
     * 获取原生锚点详情
     * https://open.oceanengine.com/labels/34/docs/1757715831323652?origin=left_nav
     *
     * @param qo
     * @return
     */
    @GetMapping("/getNativeAnchorDetail")
    public R getNativeAnchorDetail(GetDetailNativeAnchorV3Request qo) {
        qo.checkParam();
        NativeAnchorGetDetailV30ResponseData page = oceanEngineThirdRemoteService.getNativeAnchorDetail(qo);
        return R.ok(page);
    }

    /**
     * 批量获取锚点预览url
     * https://open.oceanengine.com/labels/34/docs/1786414975773770?origin=left_nav
     *
     * @param qo
     * @return
     */
    @GetMapping("/getNativeAnchorQrcode")
    public R getNativeAnchorQrcode(GetDetailNativeAnchorV3Request qo) {
        NativeAnchorQrcodePreviewGetV30ResponseData page = oceanEngineThirdRemoteService.getNativeAnchorQrcode(qo);
        return R.ok(page);
    }


    /**
     * 创建项目
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1740868093375503?origin=left_nav
     *
     * @param req
     * @return
     */
    @PostMapping("/createProject")
    public R createProject(@RequestBody @Validated ProjectCreateV30Request2 req) {
        req.checkParam();
        return R.ok(oceanEngineThirdRemoteService.createProject(req.getAccountId(), req));
    }

    /**
     * 批量创建项目、广告
     * //TODO
     * @param req
     * @return
     */
    @PostMapping("/createProjectPromotion")
//    @Lock4j
    public R createProjectPromotion(@RequestBody @Validated CreateProjectPromotionQo req) {
        req.checkParam();
        OceAccount account = oceAccountService.getById(req.getAccountId());
        return oceanEngineThirdRemoteService.createProjectPromotion(req.getAccountId(), req,account.getThirdAdvertiserAppCode());
    }
    /**
     * 批量创建项目、广告预览
     * @param req
     * @return
     */
    @PostMapping("/createProjectPromotionPreview")
    public R<List<ProjectPromotionAggregation>> createProjectPromotionPreview(@RequestBody @Validated CreateProjectPromotionQo req) {
        req.checkParam();
        OceAccount account = oceAccountService.getById(req.getAccountId());
        return oceanEngineThirdRemoteService.createProjectPromotionPreview(req.getAccountId(), req,account.getThirdAdvertiserAppCode());
    }

    /**
     * 获取项目列表
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1740937147595776?origin=left_nav
     *
     * @param advertiserId
     * @return
     */
    @GetMapping("/getProjectList")
    public TableDataInfo<ProjectListV30ResponseDataListInner> getProjectList(@RequestParam Long advertiserId, @RequestParam String accountId, @RequestParam(required = false) List<Long> ids, @RequestParam(required = false) ProjectListV30FilteringStatus status, @RequestParam Long pageNum, @RequestParam Long pageSize) {
        ProjectListV30ResponseData data = oceanEngineThirdRemoteService.getProjectList(accountId, advertiserId, ids, status, pageNum, pageSize);
        TableDataInfo<ProjectListV30ResponseDataListInner> respData = new TableDataInfo<>();
        respData.setCode(HttpStatus.HTTP_OK);
        respData.setMsg("查询成功");
        respData.setRows(data.getList());
        respData.setTotal(data.getPageInfo().getTotalNumber());
        return respData;
    }

    /**
     * 更新项目
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1740936504522831?origin=left_nav
     *
     * @param req
     * @return
     */
    @PostMapping("/updateProject")
    public R updateProject(@RequestBody @Validated UpdateProjectV3Request req) {
        boolean isOk = oceanEngineThirdRemoteService.updateProject(req.getAccountId().toString(), req);
        if (isOk) {
            return R.ok();
        }
        return R.fail();
    }

    /**
     * 获取可用优化目标（巨量广告升级版）
     * https://open.oceanengine.com/labels/7/docs/1740944984250381
     *
     * @param qo
     * @return
     */
    @GetMapping("/getEventManagerOptimizedGoal")
    public R getEventManagerOptimizedGoal(GetEventManagerV3Request qo) {
        EventManagerOptimizedGoalGetV2V30ResponseData page = oceanEngineThirdRemoteService.getEventManagerOptimizedGoal(qo);
        return R.ok(page);
    }

    /**
     * 获取可用深度优化方式（广告投放升级版）
     * https://open.oceanengine.com/labels/7/docs/1754875889727563?origin=left_nav
     *
     * @param qo
     * @return
     */
    @GetMapping("/getEventManagerDeepBidType")
    public R getEventManagerDeepBidType(GetEventManagerDeepBidTypeV3Request qo) {
        EventManagerDeepBidTypeGetV30ResponseData page = oceanEngineThirdRemoteService.getEventManagerDeepBidType(qo);
        return R.ok(page);
    }

    /**
     * 批量更新项目状态
     * https://open.oceanengine.com/labels/34/docs/1740941413906432?origin=left_nav
     *
     * @param qo
     * @return
     */
    @PostMapping("/updateProjectStats")
    public R updateProjectStats(@RequestBody @Validated UpdateProjectStatusV3Request qo) {
        Boolean isOk = oceanEngineThirdRemoteService.updateProjectStats(qo);
        if (isOk) {
            return R.ok();
        }
        return R.fail();
    }

    /**
     * 批量删除项目
     * https://open.oceanengine.com/labels/34/docs/1740944781036608?origin=left_nav
     *
     * @param qo
     * @return
     */
    @PostMapping("/deleteProject")
    public R deleteProject(@RequestBody @Validated DeleteProjectV3Request qo) {
        ProjectDeleteV30ResponseData isOk = oceanEngineThirdRemoteService.deleteProject(qo);
        return R.ok(isOk);
    }

    /**
     * 创建广告
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1740946299496459?origin=left_nav
     *
     * @param req
     * @return
     */
    @PostMapping("/createPromotion")
    public R createPromotion(@RequestBody @Validated CreatePromotionV3Request req) {
        boolean isOk = oceanEngineThirdRemoteService.createPromotion(req.getAccountId(), req);
        if (isOk) {
            return R.ok();
        }
        return R.fail();
    }

    /**
     * 修改广告
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1740952287987719?origin=left_nav
     *
     * @param req
     * @return
     */
    @PostMapping("/updatePromotion")
    public R updatePromotion(@RequestBody @Validated UpdatePromotionV3Request req) {
        boolean isOk = oceanEngineThirdRemoteService.updatePromotion(req.getAccountId().toString(), req);
        if (isOk) {
            return R.ok();
        }
        return R.fail();
    }

    /**
     * 获取广告列表
     * 文档地址：https://open.oceanengine.com/labels/34/docs/1740937147595776?origin=left_nav
     *
     * @param req
     * @return
     */
    @GetMapping("/getPromotionList")
    public TableDataInfo<PromotionListV30ResponseDataListInner> getPromotionList(GetPromotionListV3Request req) {
        PromotionListV30ResponseData data = oceanEngineThirdRemoteService.getPromotionList(req);
        TableDataInfo<PromotionListV30ResponseDataListInner> respData = new TableDataInfo<>();
        respData.setCode(HttpStatus.HTTP_OK);
        respData.setMsg("查询成功");
        respData.setRows(data.getList());
        respData.setTotal(data.getPageInfo().getTotalNumber());
        return respData;
    }

    /**
     * 批量更新广告启用状态
     * https://open.oceanengine.com/labels/34/docs/1740941413906432?origin=left_nav
     *
     * @param qo
     * @return
     */
    @PostMapping("/updatePromotiontStatus")
    public R updatePromotiontStatus(@RequestBody @Validated UpdatePromotionStatusV3Request qo) {
        Boolean isOk = oceanEngineThirdRemoteService.updatePromotiontStatus(qo);
        if (isOk) {
            return R.ok();
        }
        return R.fail();
    }

    /**
     * 批量删除广告
     * https://open.oceanengine.com/labels/34/docs/1740941413906432?origin=left_nav
     *
     * @param qo
     * @return
     */
    @PostMapping("/deletePromotiont")
    public R deletePromotiont(@RequestBody @Validated DeletePromotionV3Request qo) {
        Boolean isOk = oceanEngineThirdRemoteService.deletePromotiont(qo);
        if (isOk) {
            return R.ok();
        }
        return R.fail();
    }

    /**
     * 获取行政信息
     * https://open.oceanengine.com/labels/7/docs/1709606596424718
     *
     * @param qo
     * @return
     */
    @GetMapping("/getAdminInfo")
    public R getAdminInfo(GetAdminInfoV2Request qo) {
        ToolsAdminInfoV2ResponseData page = oceanEngineThirdRemoteService.getAdminInfo(qo);
        return R.ok(page);
    }


}
